package com.atguigu.gmall.web.controller;

import com.atguigu.gmall.common.result.Result;
import com.atguigu.gmall.feign.product.CategoryFeignClient;
import com.atguigu.gmall.product.vo.CategoryTreeVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;

import java.util.List;

/**
 * @ClassName: IndexController
 * @Author: WDD
 * @CreateTime: 2022-12-07  21:33
 * @Description:
 */
@Controller
public class IndexController {

    @Autowired
    CategoryFeignClient categoryFeignClient;

    @GetMapping("/")
    public String index(Model model){
        Result<List<CategoryTreeVo>> result = categoryFeignClient.getCategoryTree();
        List<CategoryTreeVo> list = result.getData();
        model.addAttribute("list",list);
        return "index/index";
    }
}
